﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XSLT
{
    class Program
    {
        static string[] args;

        static void Main(string[] args)
        {
            Program.args = args;

            if (args.Length == 1)
                if (args[0] == "-help")
                {
                    Console.WriteLine("Optimizer.exe -help");

                    Console.WriteLine("Optimizer.exe -cmd=listproblems -output=problems.xml");
                    Console.WriteLine("Optimizer.exe -cmd=listsolvers -output=solvers.xml");
                    Console.WriteLine("Optimizer.exe -cmd=execute -input=experiment001.xml -output=experiment002.xml -parallelismlevel=8");
                    Console.WriteLine("Optimizer.exe -cmd=compile -input=demoproblem.cs -output=demoproblem.dll");
                    Console.WriteLine("Optimizer.exe -cmd=exportcsv -input=experiment001.xml -output=experiment001.csv");

                    return;
                }


            string inputFileName = GetParameter("-input");
            string outputFileName = GetParameter("-output");
            string styleFileName = GetParameter("-style");

            var myXslTrans = new System.Xml.Xsl.XslCompiledTransform();
            myXslTrans.Load(styleFileName);
            myXslTrans.Transform(inputFileName, outputFileName); 
        }

        static private string GetParameter(string name)
        {
            string result;

            result = args.First((s) => (s.StartsWith(name)));
            result = result.Replace(name + "=", "");

            return result;
        }
    }
}
